home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
SETPAL.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-04-16
|
3KB
|
184 lines
DOSSEG
.MODEL LARGE
include extern.inc
EXTRN htoi:FAR
EXTRN itoh:FAR
EXTRN _sprintf:FAR
EXTRN ReturnValue:FAR
EXTRN stoh:FAR
.DATA
setreg_name db 'setreg',0
setpal_name db 'setpal',0
getpal_name db 'getpal',0
getreg_name db 'getreg',0
format db "%d,%d,%d",0
buffer db 20 dup (' ')
Pool PoolStruct <setreg_name,setreg,,HANDLER>
PoolStruct <setpal_name,setpal,,HANDLER>
PoolStruct <getpal_name,getpal,,FUNCTION>
PoolStruct <getreg_name,getreg,,FUNCTION>
PoolStruct <> ;END
.CODE
setpal:
push bp
mov bp,sp
push di
cmp byte ptr [bp+6],4 ;Need color and value
jne SP2
mov di,20 ;stack offset of blue
SP1: push di ;save stack offset
les di,[bp+di] ;ES:DI = hColorValue
push es
push di
call htoi ;AX = color value
pop di ;get original stack offset
push ax ;save color value on stack
sub di,4 ;next parameter
cmp di,8 ;done yet?
jae SP1
;there are now four colors on the stack
pop bx ;Color Number
pop ax ;red
mov dh,al
pop ax ;green
mov ch,al
pop ax ;blue
mov cl,al
mov ax,1010h ;Set 1 DAC Color
int 10h
SP2:
pop di
pop bp
mov ax,STOP ;terminate this message
retf
;
; This routine sets a color in the palette to another value. For example,
; if you wanted all of the red to become blue, use the command:
;
; setreg red,blue;
;
setreg:
push bp
mov bp,sp
mov ax,[bp+6] ;NUMARGS
cmp ax,2
jne SR1
les bx,[bp+8] ;color
push es
push bx
call htoi
push ax ;AX = color
les bx,[bp+12]
push es
push bx
call htoi
pop bx ;AX = value, BX = color
mov bh,al
mov ax,1000h
int 10h
SR1:
mov ax,STOP
pop bp
retf
getpal:
push bp
mov bp,sp
cmp byte ptr [bp+6],1
jne GP1
les bx,[bp+8] ;ES:BX = hColorValue
push es
push bx
call htoi ;AX = color value
mov bx,ax
mov ax,1015h
int 10h
xor ah,ah ;AH = 0
mov al,cl ;AX = blue
push ax
mov al,ch ;AX = green
push ax
mov al,dh ;AX = red
push ax
push ds
mov ax,offset format
push ax
push ds
mov ax,offset buffer
push ax
call _sprintf
add sp,14
push ds
mov ax,offset buffer
push ax
call stoh
push dx
push ax
call ReturnValue
GP1:
mov ax,STOP
pop bp
retf
getreg:
push bp
mov bp,sp
cmp byte ptr [bp+6],1
jne GR1
les bx,[bp+8] ;ES:BX = hColorValue
push es
push bx
call htoi ;AX = color value
mov bx,ax
mov ax,1007h
int 10h
mov bl,bh
xor bh,bh
push bx
call itoh
push dx
push ax
call ReturnValue
GR1:
mov ax,STOP
pop bp
retf
END